package org.thread.test05.syn.homework.demo02.test02;

/**
 * 打印线程
 *
 * @author CSY
 * @date 2025 - 03 - 12
 */
public class MyRannable implements Runnable {
    private User user;

    public MyRannable() {
    }

    public MyRannable(User user) {
        this.user = user;
    }

    @Override
    public void run() {
        showMsg();
    }

    private synchronized void showMsg() {
        String[] s = user.getMsg().split("");
        System.out.print(user.getName() + "：");
        for (Integer i = 0; i < s.length; i++) {
            System.out.print(s[i]);
        }
    }
}
